<template>
	<view class="main">
		<view class="items">
			<view class="item">
				<view class="title">姓名：</view>
				<view class="content">{{data.username}}</view>
			</view><!-- item -->
			<view class="item">
				<view class="title">性别：</view>
				<view class="content" v-if="data.sex == 1">男</view>
				<view class="content" v-else-if="data.sex == 1">女</view>
				<view class="content" v-else>其他</view>
			</view><!-- item -->
			<view class="item">
				<view class="title">年龄：</view>
				<view class="content">{{data.age}}岁</view>
			</view><!-- item -->
			<view class="item">
				<view class="title">病历号：</view>
				<view class="content">{{data.no}}</view>
			</view><!-- item -->
			<view class="item">
				<view class="title">日期：</view>
				<view class="content">{{data.see_time}}</view>
			</view><!-- item -->
			<view class="item">
				<view class="title">主诉：</view>
				<view class="content">{{data.main_chinf !=""?data.main_chinf:"-"}}</view>
			</view><!-- item -->
			<view class="item">
				<view class="title">现病史：</view>
				<view class="content">{{data.hpi !=""?data.hpi:"-"}}</view>
			</view><!-- item -->
			<view class="item">
				<view class="title">既往史：</view>
				<view class="content">{{data.history !=""?data.history:"-"}}</view>
			</view><!-- item -->
			<view class="item">
				<view class="title">专科检查：</view>
				<view class="content">
					{{data.content}}
				</view>
			</view><!-- item -->
			<view class="item">
				<view class="title">初步诊断：</view>
				<view class="content">{{data.primary_diagnosis !=""?data.primary_diagnosis:"-"}}</view>
			</view><!-- item -->
			<view class="item">
				<view class="title">处理意见：</view>
				<view class="content">{{data.handle_advise !=""?data.handle_advise:"-"}}</view>
			</view><!-- item -->
			<view class="item">
				<view class="title">矫正方案：</view>
				<view class="content">{{data.fa !=""?data.fa:"-"}}</view>
			</view><!-- item -->
		</view>
		
		
	</view><!-- main end-->
</template>

<script>
	export default {
		data() {
			return {
				data:undefined
			}
		},
		onLoad(options) {
			let queryString = options.data;  
			  
			// 将字符串转换回 JSON 对象  
			try {  
				let data = JSON.parse(decodeURIComponent(queryString)); 
				this.handleData(data);
				console.log(data); // 输出 JSON 对象  
			} catch (e) {  
				console.error('解析 JSON 失败', e);  
			}  
		},
		methods: {
			handleData(row){
				let history  = '';
				if(row.show){
					if(row.show.jbs){
						history += '疾病史：否;';
					}else{
						history += row.show.jbs_text+';';
					}
					if(row.show.bms){
						history += '过敏史：否;';
					}else{
						history += row.show.bms_text+';';
					}
					if(row.show.sss){
						history += '手术史：否;';
					}else{
						history += row.show.sss_text+';';
					}
					if(row.show.jzs){
						history += '家族史：否;';
					}else{
						history += row.show.jzs_text+';';
					}
					if(row.show.qt.length > 0){
						history += row.show.qt+';';
					}
				}
				let fa  = '';
				if(row.show && row.show.programme.length > 0){
					let ids = row.show.programme.split(',').map(Number);
					ids.forEach(function(item,index){
						if(item == 1){
							fa+="普通单光镜;";
						}else if(item == 2){
							fa+="棱镜;";
						}else if(item == 3){
							fa+="渐进多焦镜;";
						}else if(item == 4){
							fa+="近视离焦镜;";
						}else if(item == 5){
							fa+="成长乐;";
						}else if(item == 6){
							fa+="美德可儿;";
						}else if(item == 7){
							fa+="大直径RGP;";
						}else if(item == 8){
							fa+="多焦点软镜;";
						}else if(item == 9){
							fa+="软镜;";
						}else if(item == 10){
							fa+="CME减负镜;";
						}
					});
					
				}
				//预检信息
				let content = '';
				if(row.record){
					//原镜检测
					if(row.record.yjjc_qj_right.length > 0 || row.record.yjjc_qj_left.length > 0){
						content += '原镜检测：'
					}
					if(row.record.yjjc_qj_right.length > 0){
						content += 'R：'+row.record.yjjc_qj_right+'/'+row.record.yjjc_zj_right+'X'+row.record.yjjc_zw_right+';';
					}
					if(row.record.yjjc_qj_left.length > 0){
						content += 'L：'+row.record.yjjc_qj_left+'/'+row.record.yjjc_zj_left+'X'+row.record.yjjc_zw_left+";";
					}
					//电脑验光
					if(row.record.dnyg_qj_right.length > 0 || row.record.dnyg_qj_left.length > 0){
						content += '电脑验光：'
					}
					if(row.record.dnyg_qj_right.length > 0){
						content += 'R：'+row.record.dnyg_qj_right+'/'+row.record.dnyg_zj_right+'X'+row.record.dnyg_zw_right+';';
					}
					if(row.record.dnyg_qj_left.length > 0){
						content += 'L：'+row.record.dnyg_qj_left+'/'+row.record.dnyg_zj_left+'X'+row.record.dnyg_zw_right+";";
					}
					//主觉验光
					if(row.record.zjyg_qj_right.length > 0 || row.record.zjyg_qj_left.length > 0){
						content += '主觉验光：'
					}
					if(row.record.zjyg_qj_right.length > 0){
						content += 'R：'+row.record.zjyg_qj_right+'/'+row.record.zjyg_zj_right+'X'+row.record.zjyg_zw_right+'='+row.record.zjyg_jzsl_right+";下架光："+row.record.zjyg_xjg_right+",棱镜："+row.record.zjyg_lj_right+';';
						
					}
					if(row.record.zjyg_qj_left.length > 0){
						content += 'L：'+row.record.zjyg_qj_left+'/'+row.record.zjyg_zj_left+'X'+row.record.zjyg_zw_left+'='+row.record.zjyg_jzsl_left+";下架光："+row.record.zjyg_xjg_left+",棱镜："+row.record.zjyg_lj_left+';';
					}
					//扩瞳验光
					if(row.record.ktyg_qj_right.length > 0 || row.record.ktyg_qj_left.length > 0){
						content += '扩瞳验光：'
					}
					if(row.record.ktyg_qj_right.length > 0){
						content += 'R：'+row.record.ktyg_qj_right+'/'+row.record.ktyg_zj_right+'X'+row.record.ktyg_zw_right+'='+row.record.ktyg_jzsl_right+";其他："+row.record.ktyg_else_right+';';
					}
					if(row.record.ktyg_qj_left.length > 0){
						content += 'L：'+row.record.ktyg_qj_left+'/'+row.record.ktyg_zj_left+'X'+row.record.ktyg_zw_left+'='+row.record.ktyg_jzsl_left+";其他："+row.record.ktyg_else_left+';';
					}
					//扩瞳验光
					if(row.record.ktyg_status == 1){
						content += '扩瞳验光否：复方托卡胺滴眼液';
					}else if(row.record.ktyg_status == 2){
						content += '扩瞳验光否：硫酸阿托品凝胶';
					}else if(row.record.ktyg_status == 3){
						content += '扩瞳验光否：其他';
					}
					//远距视力
					if(row.record.yjsl_od_sc.length > 0 || row.record.yjsl_od_cc.length > 0){
						content += '远距视力：'
					}
					if(row.record.yjsl_od_sc.length > 0){
						content += 'SC：'+'OD：'+row.record.yjsl_od_sc+';OS：'+row.record.yjsl_os_sc+';';
					}
					if(row.record.yjsl_od_cc.length > 0){
						content += 'CC:'+'OD：'+row.record.yjsl_od_cc+';OS：'+row.record.yjsl_os_cc+';';
					}
					
					//近距视力
					if(row.record.jjsl_od_sc.length > 0 || row.record.jjsl_od_cc.length > 0){
						content += '近距视力：'
					}
					if(row.record.jjsl_od_sc.length > 0){
						content += 'SC：'+'OD：'+row.record.jjsl_od_sc+';OS：'+row.record.jjsl_os_sc+';';
					}
					if(row.record.jjsl_od_cc.length > 0){
						content += 'CC:'+'OD：'+row.record.jjsl_od_cc+';OS：'+row.record.jjsl_os_cc+';';
					}
					//立体视
					if(row.record.lts.length > 0){
						content += '立体视：'+row.record.lts+';';
					}
					if(row.record.cyb == 1){
						content += '苍蝇本：圆圈;';
					}else if(row.record.cyb == 2){
						content += '苍蝇本：图案;';
					}
					//色觉
					if(row.record.sj == 1){
						content += '色觉：正常;';
					}else if(row.record.sj == 2){
						content += '色觉：红绿色盲;';
					}else if(row.record.sj == 3){
						content += '色觉：色弱;';
					}else if(row.record.sj == 4){
						content += '色觉：其他;';
					}
					
					//眼压
					if(row.record.ys_od.length > 0 || row.record.ys_os.length > 0){
						content += '眼压：'
					}
					if(row.record.ys_od.length > 0){
						content += 'OD：'+row.record.ys_od+';';
					}
					if(row.record.ys_os.length > 0){
						content += 'OS：'+row.record.ys_os+';';
					}
					//眼轴长度
					if(row.record.yzcd_od.length > 0 || row.record.yzcd_os.length > 0){
						content += '眼轴长度：'
					}
					if(row.record.yzcd_od.length > 0){
						content += 'OD：'+row.record.yzcd_od+';';
					}
					if(row.record.yzcd_os.length > 0){
						content += 'OS：'+row.record.yzcd_os+';';
					}
					//平K
					if(row.record.pk_od.length > 0 || row.record.pk_os.length > 0){
						content += '平K：'
					}
					if(row.record.pk_od.length > 0){
						content += 'OD：'+row.record.pk_od+';';
					}
					if(row.record.pk_os.length > 0){
						content += 'OS：'+row.record.pk_os+';';
					}
					//徒K
					if(row.record.tk_od.length > 0 || row.record.tk_os.length > 0){
						content += '徒K：'
					}
					if(row.record.tk_od.length > 0){
						content += 'OD：'+row.record.tk_od+';';
					}
					if(row.record.tk_os.length > 0){
						content += 'OS：'+row.record.tk_os+';';
					}
					//角膜散光
					if(row.record.jmsg_od.length > 0 || row.record.jmsg_os.length > 0){
						content += '角膜散光：'
					}
					if(row.record.jmsg_od.length > 0){
						content += 'OD：'+row.record.jmsg_od+';';
					}
					if(row.record.jmsg_os.length > 0){
						content += 'OS：'+row.record.jmsg_os+';';
					}
				}
				//视功能检查
				if(row.func){
					//原镜检测
					if(row.func.yqyd_eom_h > 0 || row.func.yqyd_eom_o > 0 || row.func.yqyd_eom_o_gs > 0){
						content += '眼球运动：';
						if(row.func.yqyd_eom_h > 0){
							if(row.func.yqyd_eom_h == 1){
								content += '完全';
							}else if(row.func.yqyd_eom_h == 2){
								content += '受限';
							}
						}
						
						if(row.func.yqyd_eom_h > 0){
							content += ' 追随：';
							if(row.func.yqyd_eom_o == 1){
								content += '平稳';
							}else if(row.func.yqyd_eom_o == 2){
								content += '不稳';
							}
						}
						
						if(row.func.yqyd_eom_o_gs > 0){
							content += ' 固视：';
							if(row.func.yqyd_eom_o_gs == 1){
								content += '良好';
							}else if(row.func.yqyd_eom_o_gs == 2){
								content += '不良';
							}
						}
						content += ';'
					}
					//调节幅度
					if(row.func.tjfd_od.length > 0 || row.func.tjfd_os.length > 0){
						content += '调节幅度：'
					}
					if(row.func.tjfd_od.length > 0){
						content += 'OD：'+row.func.tjfd_od+';';
					}
					if(row.func.tjfd_os.length > 0){
						content += 'OS：'+row.func.tjfd_os+';';
					}
					//调节灵活度
					if(row.func.tjlhd_od.length > 0 || row.func.tjlhd_os.length > 0 || row.func.tjlhd_ou.length > 0){
						content += '调节灵活度：'
					}
					if(row.func.tjlhd_od.length > 0){
						content += 'OD：'+row.func.tjlhd_od+'CPM('+row.func.tjlhd_od_cpm+');';
					}
					if(row.func.tjlhd_os.length > 0){
						content += 'OS：'+row.func.tjlhd_os+'CPM('+row.func.tjlhd_os_cpm+');';
					}
					if(row.func.tjlhd_ou.length > 0){
						content += 'OS：'+row.func.tjlhd_ou+'CPM('+row.func.tjlhd_ou_cpm+');';
					}
					//遮盖试验
					if(row.func.zgsy_yj_zw_od > 0 || row.func.zgsy_yj_zw_os > 0 || row.func.zgsy_jj_zw_od > 0 || row.func.zgsy_jj_zw_os > 0){
						content += '遮盖：';
					}
					if(row.func.zgsy_yj_zw_od > 0){
						content += '远距离：';
					}
					if(row.func.zgsy_yj_zw_od == 1){
						content += '内隐斜：';
					}else if(row.func.zgsy_yj_zw_od == 2){
						content += '外隐斜：';
					}
					
					if(row.func.zgsy_yj_zw_od_text.length > 0){
						content += row.func.zgsy_yj_zw_od_text+';';
					}
					
					if(row.func.zgsy_yj_zw_os == 1){
						content += '内斜视：';
					}else if(row.func.zgsy_yj_zw_os == 2){
						content += '外斜视：';
					}
					
					if(row.func.zgsy_yj_zw_os_text.length > 0){
						content += row.func.zgsy_yj_zw_os_text+';';
					}
					
					if(row.func.zgsy_jj_zw_od > 0 || row.func.zgsy_jj_zw_os > 0){
						content += '近距离：';
					}
					if(row.func.zgsy_jj_zw_od == 1){
						content += '内隐斜：';
					}else if(row.func.zgsy_jj_zw_od == 2){
						content += '外隐斜：';
					}
					if(row.func.zgsy_jj_zw_od_text.length > 0){
						content += row.func.zgsy_jj_zw_od_text+';';
					}
					
					if(row.func.zgsy_jj_zw_os == 1){
						content += '内斜视：';
					}else if(row.func.zgsy_jj_zw_os == 2){
						content += '外斜视：';
					}
					if(row.func.zgsy_jj_zw_os_text.length > 0){
						content += row.func.zgsy_jj_zw_os_text+';';
					}
					
					//集合近点
					if(row.func.jhjd_pl.length > 0 || row.func.jhjd_hf.length >0){
						content += '集合近点：'+row.func.jhjd_pl+'/'+row.func.jhjd_hf+';';
					}
					
					//聚散灵活度
					if(row.func.jslhd_yj.length > 0 || row.func.jslhd_jj.length > 0){
						content += '聚散灵活度：'
					}
					if(row.func.jslhd_yj.length > 0){
						content += "远距离："+row.func.jslhd_yj+'CPM('+row.func.jslhd_yj_cpm+');'
					}
					if(row.func.tjlhd_os.length > 0){
						content += "远距离："+row.func.jslhd_jj+'CPM('+row.func.jslhd_jj_cpm+');';
					}
					//处理意见
					if(row.func.hand_advise.length > 0){
						content += '处理意见：'+row.func.hand_advise+';';
					}
				}
				
				//裂隙灯检查
				if(row.lamp){
					//眼睑
					if(row.lamp.yj_od.length > 0 || row.lamp.yj_os.length > 0){
						content += '眼睑：'
					}
					if(row.lamp.yj_od.length > 0){
						content += 'OD：'+row.lamp.yj_od+';';
					}
					if(row.lamp.yj_os.length > 0){
						content += 'OS：'+row.lamp.yj_os+';';
					}
					//倒睫
					if(row.lamp.dj_od.length > 0 || row.lamp.dj_os.length > 0){
						content += '倒睫：'
					}
					if(row.lamp.dj_od.length > 0){
						content += 'OD：'+row.lamp.dj_od+';';
					}
					if(row.lamp.dj_os.length > 0){
						content += 'OS：'+row.lamp.dj_os+';';
					}
					//眼睑闭合
					if(row.lamp.yjbh_od.length > 0 || row.lamp.yjbh_os.length > 0){
						content += '眼睑闭合：'
					}
					if(row.lamp.yjbh_od.length > 0){
						content += 'OD：'+row.lamp.yjbh_od+';';
					}
					if(row.lamp.yjbh_os.length > 0){
						content += 'OS：'+row.lamp.yjbh_os+';';
					}
					if((row.lamp.yjbh_od.length > 0 || row.lamp.yjbh_os.length > 0) && row.lamp.yj_else.length > 0){
						content += '其他：'+row.lamp.yj_else+';';
					}
					
					//泪器
					if(row.lamp.lq_od.length > 0 || row.lamp.lq_os.length > 0){
						content += '泪器：'
					}
					if(row.lamp.lq_od.length > 0){
						content += 'OD：'+row.lamp.lq_od+';';
					}
					if(row.lamp.lq_os.length > 0){
						content += 'OS：'+row.lamp.lq_os+';';
					}
					//泪点
					if(row.lamp.ld_od.length > 0 || row.lamp.ld_os.length > 0){
						content += '泪点：'
					}
					if(row.lamp.ld_od.length > 0){
						content += 'OD：'+row.lamp.ld_od+';';
					}
					if(row.lamp.ld_os.length > 0){
						content += 'OS：'+row.lamp.ld_os+';';
					}
					if((row.lamp.ld_od.length > 0 || row.lamp.ld_os.length > 0) && row.lamp.ld_else.length > 0){
						content += '其他：'+row.lamp.ld_else+';';
					}
					
					//结膜
					if(row.lamp.jm_od.length > 0 || row.lamp.jm_os.length > 0){
						content += '结膜：'
					}
					if(row.lamp.jm_od.length > 0){
						content += 'OD：'+row.lamp.jm_od+';';
					}
					if(row.lamp.jm_os.length > 0){
						content += 'OS：'+row.lamp.jm_os+';';
					}
					if((row.lamp.jm_od.length > 0 || row.lamp.jm_os.length > 0) && row.lamp.jm_else.length > 0){
						content += '其他：'+row.lamp.jm_else+';';
					}
					
					//角膜
					if(row.lamp.jo_od.length > 0 || row.lamp.jo_os.length > 0){
						content += '角膜：'
					}
					if(row.lamp.jo_od.length > 0){
						content += 'OD：'+row.lamp.jo_od+';';
					}
					if(row.lamp.jo_os.length > 0){
						content += 'OS：'+row.lamp.jo_os+';';
					}
					if((row.lamp.jo_od.length > 0 || row.lamp.jo_os.length > 0) && row.lamp.jo_else.length > 0){
						content += '其他：'+row.lamp.jo_else+';';
					}
					
					//前房
					if(row.lamp.qf_od.length > 0 || row.lamp.qf_os.length > 0){
						content += '前房：'
					}
					if(row.lamp.qf_od.length > 0){
						content += 'OD：'+row.lamp.qf_od+';';
					}
					if(row.lamp.qf_os.length > 0){
						content += 'OS：'+row.lamp.qf_os+';';
					}
					if((row.lamp.qf_od.length > 0 || row.lamp.qf_os.length > 0) && row.lamp.qf_else.length > 0){
						content += '其他：'+row.lamp.qf_else+';';
					}
					
					//虹膜
					if(row.lamp.hm_od.length > 0 || row.lamp.hm_os.length > 0){
						content += '虹膜：'
					}
					if(row.lamp.hm_od.length > 0){
						content += 'OD：'+row.lamp.hm_od+';';
					}
					if(row.lamp.hm_os.length > 0){
						content += 'OS：'+row.lamp.hm_os+';';
					}
					if((row.lamp.hm_od.length > 0 || row.lamp.hm_os.length > 0) && row.lamp.hm_else.length > 0){
						content += '其他：'+row.lamp.hm_else+';';
					}
					
					//瞳孔
					if(row.lamp.tk_od.length > 0 || row.lamp.tk_os.length > 0){
						content += '瞳孔：'
					}
					if(row.lamp.tk_od.length > 0){
						content += 'OD：'+row.lamp.tk_od+';';
					}
					if(row.lamp.tk_os.length > 0){
						content += 'OS：'+row.lamp.tk_os+';';
					}
					if((row.lamp.tk_od.length > 0 || row.lamp.tk_os.length > 0) && row.lamp.tk_else.length > 0){
						content += '其他：'+row.lamp.tk_else+';';
					}
					//晶体
					if(row.lamp.jt_od.length > 0 || row.lamp.jt_os.length > 0){
						content += '晶体：'
					}
					if(row.lamp.jt_od.length > 0){
						content += 'OD：'+row.lamp.jt_od+';';
					}
					if(row.lamp.jt_os.length > 0){
						content += 'OS：'+row.lamp.jt_os+';';
					}
					if((row.lamp.jt_od.length > 0 || row.lamp.jt_os.length > 0) && row.lamp.jt_else.length > 0){
						content += '其他：'+row.lamp.jt_else+';';
					}
					//玻璃体
					if(row.lamp.blt_od.length > 0 || row.lamp.blt_os.length > 0){
						content += '玻璃体：'
					}
					if(row.lamp.blt_od.length > 0){
						content += 'OD：'+row.lamp.blt_od+';';
					}
					if(row.lamp.blt_os.length > 0){
						content += 'OS：'+row.lamp.blt_os+';';
					}
					if((row.lamp.blt_od.length > 0 || row.lamp.blt_os.length > 0) && row.lamp.blt_else.length > 0){
						content += '其他：'+row.lamp.blt_else+';';
					}
				}
				
				
				this.data = {
					username:row.userinfo.name,
					sex:row.userinfo.sex,
					age:row.userinfo.age,
					no:row.userinfo.no,
					see_time:row.see_time,
					main_chinf:row.show?row.show.main_chinf:'',
					hpi:row.show?row.show.hpi:'',
					history:history,
					primary_diagnosis:row.show?row.show.primary_diagnosis:'',
					handle_advise:row.show?row.show.handle_advise:'',
					fa:fa,
					content:content
				};
				
				console.info(this.data)
			}
		}
	}
</script>

<style lang="scss">
	page {
	  width: 100%;
	  height: 100%;
	  background-color: white;
	}
	.main {
		display: flex;
		flex-direction: column;
		// align-items: center;
		padding-bottom: 0;  
		padding-bottom: constant(safe-area-inset-bottom);  
		padding-bottom: env(safe-area-inset-bottom); 
		.mb100{
			padding-bottom: 150rpx;
		}
		
		.items{
			display: flex;
			flex-direction: column;
			background-color: white;
			.item{
				display: flex;
				flex-direction: row;
				background-color: white;
				.title{
					font-size: 32rpx;
					font-weight: bold;
					color: black;
					height: 100rpx;
					line-height: 100rpx;
					width: 160rpx;
					margin-left: 30rpx;
				}
				.content{
					flex: 1;
					padding: 30rpx;
				}
			}
		}
	}
</style>
